package weekMatch.two_103;

import java.util.Arrays;
import java.util.Comparator;

public class LeeCode_04_3 {
    public static void main(String[] args) {

    }

    private static long countOperationsToEmptyArray(int[] nums) {
        int n = nums.length;
        Integer[] id = new Integer[n];
        for (int i = 0; i < n; ++i) {
            id[i] = i;
        }
        Arrays.sort(id, Comparator.comparingInt(i -> nums[i]));
        long ans = n;
        for (int k = 1; k < n; ++k) {
            if (id[k] < id[k - 1]){
                ans += n - k;
            }
        }
        return ans;
    }
}
